home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50b Issue 142 (CD142b) (August 1998).iso / handson / Java / sc20form.jar / com / supercede / forms / SuperCedeWindow.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-28  |  5.9 KB  |  247 lines

  1. package com.supercede.forms;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.AWTEvent;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Frame;
  8. import java.awt.Graphics;
  9. import java.awt.Point;
  10. import java.awt.Window;
  11. import java.awt.event.WindowEvent;
  12. import java.io.IOException;
  13. import java.io.InvalidObjectException;
  14. import java.io.ObjectInputStream;
  15. import java.io.Serializable;
  16. import java.util.Vector;
  17.  
  18. public class SuperCedeWindow extends Window implements SuperCedeDesignContainer, Serializable {
  19.    SuperCedeRuntimeInfo runtimeInfo;
  20.    SuperCedeDesignInfo designInfo;
  21.    transient boolean designMode;
  22.    transient DesignModeListener formListener;
  23.    transient Vector scContainerListeners;
  24.    Point shadowLocation;
  25.    boolean shadowEnabled;
  26.    private static final long serialVersionUID = 1013082004010516615L;
  27.    private static final int _version = 1;
  28.    private int version;
  29.  
  30.    public SuperCedeWindow() {
  31.       this(new Frame());
  32.    }
  33.  
  34.    public SuperCedeWindow(Frame var1) {
  35.       super(var1);
  36.       this.version = 1;
  37.       this.runtimeInfo = new SuperCedeRuntimeInfo();
  38.       this.designInfo = new SuperCedeDesignInfo();
  39.       this.designMode = false;
  40.       this.formListener = null;
  41.       this.scContainerListeners = null;
  42.       this.shadowEnabled = super.isEnabled();
  43.       this.shadowLocation = new Point(0, 0);
  44.    }
  45.  
  46.    public final void initializeThis(Vector var1) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException {
  47.       this.designInfo = null;
  48.       this.runtimeInfo = null;
  49.       SuperCedeHelper.runTimeConstructor(this, var1);
  50.       ((Component)this).setLocation(this.shadowLocation);
  51.       ((Component)this).enableEvents(64L);
  52.       this.validateObject();
  53.    }
  54.  
  55.    public Component[] getContainedComponents() {
  56.       return ((Container)this).getComponents();
  57.    }
  58.  
  59.    public void initializeFrom(SuperCedeContainer var1) throws ClassCastException, SuperCedeInvalidStateException {
  60.       try {
  61.          this.setDesignMode(((SuperCedeDesignContainer)var1).isDesignMode());
  62.          this.setFormListener(((SuperCedeDesignContainer)var1).getFormListener());
  63.          this.runtimeInfo = var1.getRuntimeInfo();
  64.          this.designInfo = ((SuperCedeDesignContainer)var1).getDesignInfo();
  65.          SuperCedeHelper.convertContainer((Container)var1, this);
  66.          if (!this.isDesignMode()) {
  67.             this.runtimeInfo = null;
  68.             this.designInfo = null;
  69.          }
  70.       } catch (ClassCastException var3) {
  71.          throw var3;
  72.       }
  73.    }
  74.  
  75.    public SuperCedeDesignInfo getDesignInfo() {
  76.       return this.designInfo;
  77.    }
  78.  
  79.    public SuperCedeRuntimeInfo getRuntimeInfo() {
  80.       return this.runtimeInfo;
  81.    }
  82.  
  83.    public void addComponent(Component var1, Object var2) {
  84.       this.addComponent(var1, var2, -1);
  85.    }
  86.  
  87.    public void addComponent(Component var1, Object var2, int var3) {
  88.       this.add(var1, var2, var3);
  89.       this.runtimeInfo.addLayoutConstraints(var1, var2);
  90.    }
  91.  
  92.    public void add(Component var1, Object var2, int var3) {
  93.       super.add(var1, var2, var3);
  94.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  95.          ((Applet)var1).start();
  96.       }
  97.  
  98.    }
  99.  
  100.    public void removeComponent(int var1) {
  101.       this.removeComponent(((Container)this).getComponent(var1));
  102.    }
  103.  
  104.    public void removeComponent(Component var1) {
  105.       this.runtimeInfo.removeLayoutConstraints(var1);
  106.       this.remove(var1);
  107.    }
  108.  
  109.    public void remove(Component var1) {
  110.       if (((Component)this).isVisible() && var1 instanceof Applet) {
  111.          ((Applet)var1).stop();
  112.       }
  113.  
  114.       super.remove(var1);
  115.    }
  116.  
  117.    public boolean isEnabled() {
  118.       return this.shadowEnabled;
  119.    }
  120.  
  121.    public void setEnabled(boolean var1) {
  122.       this.shadowEnabled = var1;
  123.       if (!this.isDesignMode()) {
  124.          super.setEnabled(var1);
  125.       }
  126.  
  127.    }
  128.  
  129.    public void paint(Graphics var1) {
  130.       if (this.formListener != null) {
  131.          this.formListener.paint(var1);
  132.       }
  133.  
  134.       super.paint(var1);
  135.    }
  136.  
  137.    public void addNotify() {
  138.       super.addNotify();
  139.       if (this.formListener != null) {
  140.          this.formListener.addedPeer();
  141.       }
  142.  
  143.    }
  144.  
  145.    public void removeNotify() {
  146.       if (this.formListener != null) {
  147.          this.formListener.removingPeer();
  148.       }
  149.  
  150.       super.removeNotify();
  151.    }
  152.  
  153.    public Object getLayoutConstraints(Component var1) {
  154.       return this.runtimeInfo.getLayoutConstraints(var1);
  155.    }
  156.  
  157.    public Object getLayoutConstraints(int var1) {
  158.       return this.getLayoutConstraints(((Container)this).getComponent(var1));
  159.    }
  160.  
  161.    public void setDesignMode(boolean var1) {
  162.       this.designMode = var1;
  163.    }
  164.  
  165.    public boolean isDesignMode() {
  166.       return this.designMode;
  167.    }
  168.  
  169.    public void setFormListener(DesignModeListener var1) {
  170.       this.formListener = var1;
  171.    }
  172.  
  173.    public DesignModeListener getFormListener() {
  174.       return this.formListener;
  175.    }
  176.  
  177.    protected void processWindowEvent(WindowEvent var1) {
  178.       if (((AWTEvent)var1).getID() == 201 && this.scContainerListeners != null) {
  179.          SuperCedeContainerEvent var3 = new SuperCedeContainerEvent(this, 4434);
  180.          synchronized(this){}
  181.  
  182.          Vector var2;
  183.          try {
  184.             var2 = (Vector)this.scContainerListeners.clone();
  185.          } catch (Throwable var6) {
  186.             throw var6;
  187.          }
  188.  
  189.          for(int var4 = 0; var4 < var2.size(); ++var4) {
  190.             ((SuperCedeContainerListener)var2.elementAt(var4)).containerShutdown(var3);
  191.          }
  192.       }
  193.  
  194.       super.processWindowEvent(var1);
  195.    }
  196.  
  197.    public void addSuperCedeContainerListener(SuperCedeContainerListener var1) {
  198.       synchronized(this){}
  199.  
  200.       try {
  201.          if (this.scContainerListeners == null) {
  202.             this.scContainerListeners = new Vector();
  203.          }
  204.  
  205.          this.scContainerListeners.addElement(var1);
  206.       } catch (Throwable var4) {
  207.          throw var4;
  208.       }
  209.  
  210.    }
  211.  
  212.    public void removeSuperCedeContainerListener(SuperCedeContainerListener var1) {
  213.       synchronized(this){}
  214.  
  215.       try {
  216.          this.scContainerListeners.removeElement(var1);
  217.       } catch (Throwable var4) {
  218.          throw var4;
  219.       }
  220.  
  221.    }
  222.  
  223.    public void setVisible(boolean var1) {
  224.       if (!var1) {
  225.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), false);
  226.       }
  227.  
  228.       super.setVisible(var1);
  229.       if (var1) {
  230.          SuperCedeHelper.setAppletVisibility(this, this.isDesignMode(), true);
  231.       }
  232.  
  233.    }
  234.  
  235.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  236.       var1.defaultReadObject();
  237.  
  238.       try {
  239.          SuperCedeHelper.doDeserializationProcessing(this);
  240.       } catch (SuperCedeInvalidStateException var2) {
  241.       }
  242.    }
  243.  
  244.    public void validateObject() throws InvalidObjectException {
  245.    }
  246. }
  247.